<template>
	<view class="uni-flex uni-align-center uni-justify-center">
		<radio :checked="innerValue" @click="check">
			<text>我已阅读并同意</text>
			<text :style="{ color: color }" @click.prevent="link(0)">用户协议</text>
			<text>和</text>
			<text :style="{ color: color }" @click.prevent="link(1)">隐私政策</text>
		</radio>
	</view>
</template>
<script>
	export default {
		name: 'nx-agreement',
		props: {
			modelValue: {
				type: Boolean,
				default: false,
			},
			value: {
				type: Boolean,
				default: false,
			},
			color: {
				type: String,
				default: '#42b983'
			}
		},
		computed: {
			innerValue() {
				// #ifdef VUE2
				return this.value
				// #endif
				// #ifdef VUE3
				return this.modelValue
				// #endif
			}
		},
		methods: {
			check() {
				let result = !this.innerValue
				this.$emit('update:modelValue', result)
				this.$emit('input', result)
				this.$emit('change', result)
			},
			link(val) {
				this.$emit('link', val)
			}
		}
	}
</script>
<style>
</style>